<template>
</template>

<script>
	import {
		Autologin,
		getwxloginMessage
	} from './request/api.js'
	export default {
		async onLaunch() {
			// uni.login({
			// 	success: (res) => {
			// 		console.log(res, 'uni-login')
			// 		getwxloginMessage(res.code)
			// 	}
			// })

			const token = uni.getStorageSync('token');
			if (token) {
				const result = await Autologin(token);
				if (result.success) {
					if (result.role === 'student') {
						uni.switchTab({
							url: '/pages/home/index'
						});
					} else {
						uni.redirectTo({
							url: '/pages/work/index'
						});
					}
					// console.log(result, '1111111')
				} else {
					// Token 验证失败，清除本地存储的 Token 并跳转到登录页面
					uni.removeStorageSync('token');
					uni.navigateTo({
						url: '/pages/login/index'
					});
				}
			}
		}
	};
</script>

<style>
	/* 全局样式 */
	page {
		height: 100%;
	}
</style>